Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bulk finalization #5734

Merged
merged 46 commits into from
Oct 2, 2023
Merged

Add bulk finalization #5734

merged 46 commits into from
Oct 2, 2023

Conversation

seadowg
Copy link
Member

@seadowg seadowg commented Sep 11, 2023

Closes #5714

This makes it possible to finalise all forms in "Drafts" without needing to open any of them. There's still a bunch of different cases and kinds of forms we need to handle, and that is all listed in "Follow on work" in the issue (I'll write these up as their own issues).

I've also made a change to our linting here so that ./gradlew checkCode does not check for hardcoded strings, but that CI does using a different lint command (lintDebug -PlintStrings). This makes it easier to work on a PR without translated strings and then add them at the end.

As this PR adds some strings, we'll need to add them to master after we merge. The strings to add are:

  • finalize_all_forms
  • bulk_finalize_success
  • bulk_finalize_failure
  • bulk_finalize_partial_success
  • incomplete

What has been done to verify that this works as intended?

New and existing tests.

Why is this the best possible solution? Were any other approaches considered?

I mainly follow the approach we're now using for forms of having a data service that accesses repos and then exposing UI state to the Activity/Fragment with a ViewModel. One thing to note is that so that this will be easier to merge in later, I've made as few changes to existing code so there are definitely missed opportunities to share the new code with the existing form loading/saving flows.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

As I said above, I've made as few changes to existing code which should hopefully also lower the risk here. In terms of testing the new functionality: it'd definitely be good to check bulk finalization with as many different kinds of forms as you can think of! The kinds of scenarios that I expect not work are listed in "Follow on work" in the issue, but still feel free to try these out if only to confirm they don't actually work.

Before submitting this PR, please make sure you have:

  • run ./gradlew checkAll and confirmed all checks still pass OR confirm CircleCI build passes and run ./gradlew connectedDebugAndroidTest locally.
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

@seadowg seadowg changed the base branch from master to v2023.3.x September 11, 2023 18:19
@seadowg
Copy link
Member Author

seadowg commented Sep 27, 2023

@alyblenkin @lognaturel just to clarify: should we mark a form that hasn't need validated yet as "incomplete" or "complete"? I was assuming "incomplete", but wanted to double check.

@alyblenkin
Copy link
Collaborator

@alyblenkin @lognaturel just to clarify: should we mark a form that hasn't need validated yet as "incomplete" or "complete"? I was assuming "incomplete", but wanted to double check.

Yes, that's what I was thinking. The goal is to give the user error feedback earlier.

  • Incomplete = saved with errors or we don't know
  • Complete = saved with no errors

And then we need to change the validation button at the end from "check for errors" to "check for completeness" once we decide that this is the language we want to move forward with.

@seadowg
Copy link
Member Author

seadowg commented Sep 27, 2023

And then we need to change the validation button at the end from "check for errors" to "check for completeness" once we decide that this is the language we want to move forward with.

Good point. Just to be clear, for this PR you'll never actually see "Complete" as there will be no way to see a form that's saved and valid in Drafts. That will come with #5718 (which I'll update for the new design).

@alyblenkin
Copy link
Collaborator

And then we need to change the validation button at the end from "check for errors" to "check for completeness" once we decide that this is the language we want to move forward with.

Good point. Just to be clear, for this PR you'll never actually see "Complete" as there will be no way to see a form that's saved and valid in Drafts. That will come with #5718 (which I'll update for the new design).

Yes exactly! Sorry I was writing it out more for my own clarity. @lognaturel let me know if you are thinking about it differently.

@lognaturel
Copy link
Member

That all sounds great to me!

"Incomplete" feels like a good choice for "we don't know" because it forces the user to open that submission again and take an explicit action. The worst case with that would be that they get stuck in a loop opening the submission, deciding everything looks good, tapping the back button to exit, again seeing "Incomplete", and repeating. Hopefully at some point they'd try the finalize/send button if their intent is to send.

If complete and "we don't know" submissions look the same, then users could assume that a particular draft is done for now and fail to capture important information. That feels worse than the possible annoying loop described above.

@seadowg seadowg requested a review from lognaturel September 28, 2023 13:25
@seadowg
Copy link
Member Author

seadowg commented Sep 28, 2023

@grzesiek2010 @lognaturel this is ready for another look. The pill/chip doesn't look quite right yet, but @alyblenkin and I discussed this and seeing as a "non-clickable" chip (something that we and it seems the Material 3 website CSS refer to as a "pill") doesn't official exist, we're going to pair on building this out properly a little later.

import java.util.Date
import java.util.Locale

object InstanceListItemView {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is not a custom view but a class that only sets its state?. This is not something we used to do.

Copy link
Member Author

@seadowg seadowg Sep 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have left a comment about this. The problem is that it's used by a SimpleCursorAdapter which does the view inflation itself - I'm trying to make as little changes to existing code as possible to make merging easier later. I didn't want to have to refactor out the cursor, so this was where I ended up. I guess maybe a better approach would be to make this a ViewHolder that takes a view in the constructor. That would be overkill for now, but would plugin straight to a RecyclerView when all this gets refactored. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that adding a comment in the class that at some point it should be a custom view as the class name says is ok for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

setUpSubtext(view, instance, context)

val chip = view.findViewById<TextView>(R.id.chip)
if (chip != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that it's null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah because the adapter sometimes uses a different layout (form_chooser_list_item_multiple_choice.xml).

disabledCause.text = disabledMessage

// Material design "disabled" opacity is 38%.
formTitle.alpha = 0.38f
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to factor out this constant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might not even be correct anymore. I'll pull it out as a constant for this file, but don't want to get distracted by restyling the whole list item right now.

@seadowg
Copy link
Member Author

seadowg commented Sep 29, 2023

@grzesiek2010 @lognaturel I think we should skip QA for this PR as it leaves things in a confusing state (all drafts end up incomplete) and then test everything as part of the PR for #5718.

@lognaturel
Copy link
Member

lognaturel commented Sep 29, 2023

I agree with merging this and then doing QA when #5718 is in.

I'm seeing the literal string "Success! %d forms finalized". Maybe that's something you intend to come back to once we finalize all language but wanted to flag in case it's unexpected.

We'll also need to trigger autosend after bulk finalization completes. That could be tracked and addressed separately.

Looks good to me beyond that!

@seadowg
Copy link
Member Author

seadowg commented Oct 2, 2023

I'm seeing the literal string "Success! %d forms finalized". Maybe that's something you intend to come back to once we finalize all language but wanted to flag in case it's unexpected.

Fixed!

@seadowg seadowg merged commit 54966e9 into getodk:v2023.3.x Oct 2, 2023
@seadowg seadowg deleted the bulk-finalization branch October 2, 2023 09:36
seadowg added a commit to seadowg/collect that referenced this pull request Oct 2, 2023
grzesiek2010 added a commit that referenced this pull request Oct 2, 2023
seadowg added a commit to seadowg/collect that referenced this pull request Oct 17, 2023
seadowg added a commit to seadowg/collect that referenced this pull request Oct 24, 2023
seadowg added a commit to seadowg/collect that referenced this pull request Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants